<!DOCTYPE html>
<html lang="en">

    <head>

        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="">

        <title>Kura's Hardware Shop</title>

        <!-- Bootstrap Core CSS -->
        <link href="css/bootstrap.min.css" rel="stylesheet">

        <!-- MetisMenu CSS -->
        <link href="css/plugins/metisMenu/metisMenu.min.css" rel="stylesheet">

        <!-- Custom CSS -->
        <link href="css/sb-admin-2.css" rel="stylesheet">

        <!-- Custom Fonts -->
        <link href="font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">

        <!-- Bootstrap Core CSS -->
        <link href="css/bootstrap.min.css" rel="stylesheet">

        <!-- MetisMenu CSS -->
        <link href="css/plugins/metisMenu/metisMenu.min.css" rel="stylesheet">

        <!-- DataTables CSS -->
        <link href="css/plugins/dataTables.bootstrap.css" rel="stylesheet">

        <!-- Custom CSS -->
        <link href="css/sb-admin-2.css" rel="stylesheet">

        <!-- Custom Fonts -->
        <link href="font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">

        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->

    </head>

    <body>
        <?php
        session_start();
        if (!isset($_SESSION['role'])) {
            header("Location: login.php");
        }
        include('script/customersScript.php');
        ?>
        <div id="wrapper">

            <!-- Navigation -->
            <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="index.html">Xin chào <?php echo $_SESSION['name'] ?></a> <!-- get User late -->
                </div>
                <!-- /.navbar-header -->

                <ul class="nav navbar-top-links navbar-right">

                    <li class="dropdown">
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <i class="fa fa-user fa-fw"></i>  <i class="fa fa-caret-down"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="info.php"><i class="fa fa-user fa-fw"></i> Thông tin cá nhân</a>
                            </li>

                            <li class="divider"></li>
                            <li><a href="script/logoutScript.php"><i class="fa fa-sign-out fa-fw"></i> Đăng xuất</a>
                            </li>
                        </ul>
                        <!-- /.dropdown-user -->
                    </li>
                    <!-- /.dropdown -->
                </ul>
                <!-- /.navbar-top-links -->

              <div class="navbar-default sidebar" role="navigation">
                    <div class="sidebar-nav navbar-collapse">
                        <ul class="nav" id="side-menu">
                            <?php
                            if ($_SESSION['role'] == 1) {
                                ?>
                                <li>
                                    <a class="active" href="statistic.php"><i class="fa fa-bar-chart-o fa"></i> &nbspThống kê<span class="fa arrow"></span></a>
                                    <ul class="nav nav-second-level">
                                        <li>
                                            <a href="statistic.php">Doanh thu</a>
                                        </li>
                                    </ul>
                                </li>

                                <li>
                                    <a href="users.php"><i class="fa fa-user fa-fw"></i> Quản lí nhân viên</a>

                                    <!-- /.nav-second-level -->
                                </li>
                                <?php
                            }
                            ?>
                            <li>
                                <a href="customers.php"><i class="fa fa-wrench fa-fw"></i>&nbsp;Quản lí khách hàng</a>

                                <!-- /.nav-second-level -->
                            </li>
                            <li>
                                <a href="#"><i class="fa fa-shopping-cart fa-fw"></i> Quản lí sản phẩm<span class="fa arrow"></span></a>
                                <ul class="nav nav-second-level">
                                    <li>
                                        <a href="categories.php">Danh mục</a>
                                    </li>
                                    <li>
                                        <a href="manufacturers.php">Nhà sản xuất</a>
                                    </li>                                    
                                    <li>
                                        <a href="products.php">Sản phẩm</a>
                                    </li>
                                </ul>
                            </li>
                            <li>

                                <a href="#"><i class="fa fa-edit fa-fw"></i> Quản lí đơn hàng<span class="fa arrow"></span></a>
                                <ul class="nav nav-second-level">
                                    <li>
                                        <a href="orders_in.php">Hóa đơn nhập</a>
                                    </li>
                                    <li>
                                        <a href="orders_out.php">Hóa đơn xuất</a>
                                    </li>

                                </ul>
                            </li>
                        </ul>
                        <!-- /.nav-second-level -->
                    </div>
                    <!-- /.sidebar-collapse -->
                </div>
                <!-- /.navbar-static-side -->
            </nav>
			
			

            <!-- Page Content -->
            <div id="page-wrapper">
			<div class="row">
                    <ul class="nav nav-tabs" role="tablist">
                        <li><a href="#new" role="tab" data-toggle="tab">Thêm mới</a></li>
                        <li class="active"><a href="#list" role="tab" data-toggle="tab">Danh sách khách hàng</a></li>
                    </ul>
                </div>
			
                 <div class="row">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <!-- /.col-lg-12 -->
                            <div class="tab-content">
                                <div id="new" class="tab-pane">
                                   <form method="POST" action="script/customersScript.php">
                                        <div class="row">
										
                                            <div class="form-group col-lg-6" >
                                                <label>Họ tên</label>
                                                <input type="text" name="name" id="name"  class="form-control">
                                            </div>
                                            <div class="form-group col-lg-6">
                                                <label>Địa chỉ</label>
                                                <input type="text" name="add" id="add" class="form-control">
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="form-group col-lg-6">
                                                <label>Số điện thoại</label>
                                                <input type="text" name="phone" id="phone" class="form-control">
                                            </div>
											<div class="form-group col-lg-6">
                                                <label>Email</label>
                                                <input type="text" name="email" id="email" class="form-control">
                                            </div>
                                        </div>

<!--Họ tên <input type="text" name="email" id="email">
                                        -->
                                        <div class="modal-footer">
                                            <input class='btn btn-primary' type="submit" name="edit" value="Thêm mới" >

                                        </div>
                                    </form>
                                </div>
                                <div id="list" class="tab-pane active">
                                    <?php printTable(); ?>
                                </div>
                            </div>
                        </div>



                        <!-- /.row -->
                    </div>
                </div>
            </div>
            <hr>
			
            <!-- /bảng cập nhật -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <h4 class="modal-title" id="myModalLabel">Cập nhật thông tin khách hàng</h4>
                    </div>
                    <div class="modal-body">
                        <form method="POST" action="script/customersScript.php">
                            <div class="form-group">
                    <label>ID</label>
                    <input type="text" name="id" id="id_val" class="form-control">
                </div>
                <div class="form-group">
                    <label>Họ tên</label>
                    <input type="text" name="name" id="name_val" class="form-control">
                </div>
                <div class="form-group">
                    <label>Địa chỉ</label>
                    <input type="text" name="add" id="add_val" class="form-control">
                </div>
                <div class="form-group">
                    <label>Số điện thoại</label>
                    <input type="text" name="phone" id="phone_val" class="form-control">
                </div>
                <div class="form-group">
                    <label>Email</label>
                    <input type="text" name="email" id="email_val" class="form-control">
                </div>

<!--Họ tên <input type="text" name="email" id="email">
                            -->
                            <div class="modal-footer">
						<!--<input class='btn btn-primary' type="submit" name="edit" value="Thêm mới" > -->
						<input class='btn btn-primary' type="submit" name="edit" value="Cập nhật" > 
						<input class='btn btn-primary' type="submit" name="edit" value="Xóa">
                            </div>
                        </form>
                    </div>                    
                </div>
            </div>
        </div>
			
			
			
          
           

            <!-- jQuery Version 1.11.0 -->
            <script src="js/jquery-1.11.0.js"></script>

            <!-- Bootstrap Core JavaScript -->
            <script src="js/bootstrap.min.js"></script>

            <!-- Metis Menu Plugin JavaScript -->
            <script src="js/plugins/metisMenu/metisMenu.min.js"></script>

            <!-- Custom Theme JavaScript -->
            <script src="js/sb-admin-2.js"></script>

            <!-- DataTables JavaScript -->
            <script src="js/plugins/dataTables/jquery.dataTables.js"></script>
            <script src="js/plugins/dataTables/dataTables.bootstrap.js"></script>

            <!-- Custom Theme JavaScript -->


            <!-- Page-Level Demo Scripts - Tables - Use for reference -->
            <script>
                $(document).ready(function() {
                    $('#dataTables-example').dataTable();
                });
            </script>

            <script>
                $("i").click(function() {
                    if ($(this).attr("value") == "edit") {
                        var gEmail = $(this).closest('tr').find('td:eq(4)').text();
                        // var gEmail = $('#dataTables-example tr ').find("td").eq(4).html();
                        $('#email_val').val(gEmail);
                        var gName = $(this).closest('tr').find('td:eq(1)').text();
                        $('#name_val').val(gName);
                        var gAdd = $(this).closest('tr').find('td:eq(2)').text();
                        $('#add_val').val(gAdd);
                        var gPhone = $(this).closest('tr').find('td:eq(3)').text();
                        $('#phone_val').val(gPhone);
                        var gID = $(this).closest('tr').find('td:eq(0)').text();
                        $('#id_val').val(gID);
                    }
                });
            </script>
    </body>

</html>
